package BuilderDemo.example;

/**
 * @author zsh
 * @Description
 * @create 2022-05-30 19:45
 */
public class TextBuilder extends Builder {
    private StringBuffer sb = new StringBuffer();
    @Override
    public void makeTitle(String title) {
        sb.append("=====================");
        sb.append("[").append(title).append("]\n");
        sb.append("\n");
    }

    @Override
    public void makeString(String str) {
        sb.append("+").append(str).append("\n");
        sb.append("\n");
    }

    @Override
    public void makeItems(String[] items) {
        for (int i = 0; i < items.length; i++) {
            sb.append("~").append(items[i]).append("\n");
        }
        sb.append("\n");
    }

    @Override
    public void close() {
        sb.append("=====================");
    }
    public String getResult(){
        return sb.toString();
    }
}
